function [f,y_fft] = FourierTransform(Data,Fs,Dim)
%This function takes an input array of data, 'Data', and outputs the result
%of the fourier transform of each row of the input array, 'FreqInt', as
%well as the frequency domain vector, 'f'.

if(strcmpi(Dim,'Hor'))
    Data = Data(:,:,1);
elseif(strcmpi(Dim,'Ver'))
    Data = (Data(:,:,1))';
end

%Remove the average offset of the data 
%(this sets the magnitude of the transform at a frequency of 0 to 0, 
%and is done to make viewing the transform easier, as this magnitude is 
%otherwise many times larger than the other magnitudes, and this value is 
%not relevant to the analysis being performed via this function)
y = double(Data) - mean(mean(Data));

%Create vector for frequency domain
n = 2*size(Data,2); %# of samples per row
nPow2 = 2^nextpow2(n);
f = Fs*(0:(nPow2/2 - 1))/nPow2; %vector for frequency domain
    
%utilize fft function to perform the transform
transform = fft(y,nPow2,2);
y_fft = transform(:,1:(size(transform,2)/2));

end

